﻿namespace S7_3UBD
{
    /// <summary>
    /// 配置文件帮助类
    /// </summary>
    public class ConfigHelper
    {
        static IConfiguration _Configuration;
        /// <summary>
        /// 设置全局变量Configuration;
        /// </summary>
        /// <param name="configuration"></param>
        public static void SetConfiguration(IConfiguration configuration)
        {
            if (_Configuration == null)
            {
                _Configuration = configuration;
            }
        }
        /// <summary>
        /// 获取数据库字符串
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string GetConnectionString(string name)
        {
           return _Configuration.GetConnectionString(name);
        }
    }

    public class Config
    {
        /// <summary>
        /// 数据库连接串
        /// </summary>
        public readonly static string DBConn = ConfigHelper.GetConnectionString("DBConn");
    }
}
